<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>SAP查询系统—江苏弘仁供应链管理有限公司 - www.wholeline.cn</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/master.css" rel="stylesheet" type="text/css" />
	<script src="${ctx}/js/jquery.js" type="text/javascript"></script>
	<script src="${ctx}/js/table.js" type="text/javascript"></script>
	<link href="${ctx}/validate/jquery.validate.css" type="text/css" rel="stylesheet"/>
	<script src="${ctx}/validate/jquery.validate.js" type="text/javascript"></script>
	<script src="${ctx}/validate/messages_cn.js" type="text/javascript"></script>
	<script>
	$(document).ready(function() {
		jQuery.validator.addMethod("validateUsername", function(value, element) {
			var username = $.trim($("#username").val());
			var re =/^[0-9A-Za-z]{1,}$/ ;
			if (!re.test(username)){ 
 		    	return false;
 		    }
 		    return true;
		}, "由英文字母和数字组成！");
		$.validator.addMethod("validateidNumber",function(value,element,params){
 	 		var card=$.trim($("#idNumber").val());
  			if(value!=''){
	 			// 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X
	 			var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
	 			if(reg.test(card) === false)
	 			{
	 				return false;
	 			}
  			}
 			return true;
		},"身份证号格式错误");
		// 手机号码验证    
		jQuery.validator.addMethod("isMobile", function(value, element) {    
		  var length = value.length;    
		  return this.optional(element) || (length == 11 && /^13\d{9}$/.test(value)||(/^15[0-35-9]\d{8}$/.test(value))|| (/^18[025-9]\d{8}$/.test(value)));   
		}, "请正确填写手机号码");    
		  
		// 电话号码验证    
		jQuery.validator.addMethod("isPhone", function(value, element) {    
		  var tel = /^(\d{3,4}-?)?\d{7,9}$/g;    
		  return this.optional(element) || (tel.test(value));    
		}, "请正确填写电话号码");
		$("#inputForm").validate({
			rules: {
				username: {
					required:true,
					validateUsername:true,
					minlength:4,
					maxlength:10,
					remote: "${ctx}/userreg!checkName.action?oldName="
				},
				password: {
					required:true,
					minlength:4,
					maxlength:10
				},
				passwordConfirm: {
					required: true,
					equalTo: "#password"
				},
				enname: {
					minlength:4,
					maxlength:18,
				},
				idNumber: {
					//required:true,
					minlength:15,
					maxlength:18,
					validateidNumber:true
				},
				name: {
					maxlength:20,
				},
				company: {
					maxlength:50,
				},
				contact: {
					maxlength:20,
				},
				mobile: {
					isMobile:true
				},
				telephone: {
					isPhone:true
				}
			},
			errorPlacement: function(error, element) {   
		        if (document.getElementById("error_"+element.attr("name")))  {
		            error.appendTo("#error_"+element.attr("name"));  
		        }
		        else {
		            error.insertAfter(element); 
		        }
		    },
		    errorElement: "strong"
		});
	});
	</script>
</head>
<body>
<div id="wrapper">
<br />
<div id="content">
<!-- head start  -->
<p></p>
<div class="nav">
</div>
<div class="top_serach_box"><p class="examination_info">用户注册</p></div>
<!-- head end  -->
<form id="inputForm" action="${ctx}/userreg!save.action" method="post" >
	<div class="top_serach_box">
        <ul class="form">
        	<li><label>用户名</label><input id="username" name="username" type="text" style="width:200px;" /></li>
		    <li><label>英文名</label><input id="enname" name="enname"  type="text" style="width:200px;" /></li>
		    <li><label>密码</label><input id="password" name="password" type="password" style="width:200px;" /></li>
		    <li><label>确认密码</label><input id="passwordConfirm" name="passwordConfirm" type="password" style="width:200px;" /></li>
		    <li><label>身份证号</label><input id="idNumber" name="idNumber" type="text" style="width:200px;" /></li>
		    <li><label>姓名</label><input id="name" name="name" type="text" style="width:200px;" /></li>
		    <li><label>工作单位</label><input id="company" name="company" type="text" style="width:200px;" /></li>
		    <li><label>联系人</label><input id="contact" name="contact" type="text" style="width:200px;" /></li>
		    <li><label>手机</label><input id="mobile" name="mobile" type="text" style="width:100px;" /></li>
		    <li><label>固定电话</label><input id="telephone" name="telephone" type="text" style="width:100px;" /></li>
	    </ul>
		<p class="button_box"><input type="submit" value="注    册" class="btn_red"/>&nbsp;&nbsp;
		<input type="button" value="取    消" onclick="javascript:history.back();" class="btn_red"/>
		</p>
	</div>
</form>

</div> <!-- content  end-->
</div><!-- wrapper  end-->  
</body>
</html>